<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Login Form with floating placeholder and light button</title>

    <link rel="stylesheet" href="css/style.css" />
  </head>
  <body>
    <div class="login-box">
      <h2>登录</h2>
      <form>
        <div class="user-box">
          <input
            class="my_text"
            type="text"
            name=""
            required=""
            placeholder="电话"
          />
          <!-- <label>用户名</label> -->
        </div>
        <div class="user-box">
          <input
            class="my_password"
            type="password"
            name=""
            required=""
            placeholder="密码"
          />
          <!-- <label>密码</label> -->
        </div>
        <a href="#" id="go">
          <span></span>
          <span></span>
          <span></span>
          <span></span>
          登录
        </a>
        <a href="./login.html" style="margin-left: 2rem">
          <span></span>
          <span></span>
          <span></span>
          <span></span>
          注册
        </a>
      </form>
    </div>
  </body>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.9.1/jquery.js"></script>
  <script>
    // 点击登录
    $("#go").click(function () {
      let text_word = $(".my_text").val();
      let password = $(".my_password").val();

      $.post(
        "http://localhost:3000/enter",
        { text_word, password },
        function ( res) {
          console.log("123");

          if (res == "success") {
            // 将账号密码存入
            localStorage.phone = text_word;
            // localStorage.password = passWord;
            console.log("登陆成功");
            location.href = "主页.html";
          } else {
            console.log("登录失败");
          }
        }
      );
    });
  </script>
</html>
